package org.linlinjava.litemall.admin.web;

import java.util.List;

import org.linlinjava.litemall.core.core.core.controller.BaseController;
import org.linlinjava.litemall.core.core.core.domain.AjaxResult;
import org.linlinjava.litemall.core.core.core.page.TableDataInfo;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.SysConfig;
import org.linlinjava.litemall.db.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 系统配置Controller
 *
 * @author ruoyi
 * @date 2025-01-23
 */
@RestController
@RequestMapping("/admin/config")
public class SysConfiController extends BaseController
{
    @Autowired
    private SysConfigService sysConfiService;

    /**
     * 查询系统配置列表
     */

    @GetMapping("/list")
    public Object list(SysConfig sysConfi)
    {
        startPage();
        List<SysConfig> list = sysConfiService.selectSysConfiList(sysConfi);

        return ResponseUtil.okList(list);
    }

    /**
     * 导出系统配置列表
     */

//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SysConfig sysConfi)
//    {
//        List<SysConfig> list = sysConfiService.selectSysConfiList(sysConfi);
//        ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfi.class);
//        util.exportExcel(response, list, "系统配置数据");
//    }

    /**
     * 获取系统配置详细信息
     */

    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysConfiService.selectSysConfiById(id));
    }

    /**
     * 新增系统配置
     */

    @PostMapping("/add")
    public AjaxResult add(@RequestBody SysConfig sysConfi)
    {
        return toAjax(sysConfiService.insertSysConfi(sysConfi));
    }

    /**
     * 修改系统配置
     */

    @PostMapping("/update")
    public AjaxResult edit(@RequestBody SysConfig sysConfi)
    {
        return toAjax(sysConfiService.updateSysConfi(sysConfi));
    }

    /**
     * 删除系统配置
     */

    @PostMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysConfiService.deleteSysConfiByIds(ids));
    }
}
